package cn.niit.service.impl;

import cn.niit.dao.ClassDao;
import cn.niit.entity.Classes;
import cn.niit.entity.Student;
import cn.niit.entity.query.ClassQuery;
import cn.niit.service.ClassService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 班级表(Classes)表服务实现类
 *
 * @author makejava
 * @since 2021-11-14 16:06:20
 */
@Service("classService")
public class ClassServiceImpl implements ClassService {
    @Resource
    private ClassDao classDao;


    @Override
    public PageInfo<Classes> queryByClass(ClassQuery classQuery) {
        PageHelper.startPage(classQuery.getPageNum(), classQuery.getPageSize());
        return new PageInfo<Classes>(classDao.queryByClass(classQuery));
    }

    @Override
    public PageInfo<Classes> queryByDepartmentCode(ClassQuery classQuery) {
        PageHelper.startPage(classQuery.getPageNum(), classQuery.getPageSize());
        return new PageInfo<Classes>(classDao.queryByDepartmentCode(classQuery));
    }

    @Override
    public PageInfo<Classes> select(ClassQuery classQuery) {
        PageHelper.startPage(classQuery.getPageNum(), classQuery.getPageSize());
        return new PageInfo<Classes>(classDao.select(classQuery));
    }

    @Override
    public boolean editClass(Classes classes) {
        int i = classDao.editClass(classes);
        return i > 0;
    }

    @Override
    public Classes queryClassById(Integer classCode) {
        return classDao.queryClassById(classCode);
    }

    @Override
    public boolean addClass(Classes classes) {
        return classDao.addClass(classes) > 0;
    }

    @Override
    public boolean deleteClassById(Integer classCode) {
        int i = classDao.deleteClassById(classCode);
        return i > 0;
    }

    /**
     * 查询所有班级列表
     *
     * @return
     */
    @Override
    public List<Classes> queryAllClass() {
        return classDao.queryByClass(null);
    }
}